package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoArtMajors;
import com.muyu.danmo.service.IDanmoArtMajorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 学院专业Controller
 * 
 * @author yangle
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/danmoArtMajors")
public class DanmoArtMajorsController extends BaseController
{
    @Autowired
    private IDanmoArtMajorsService danmoArtMajorsService;

    /**
     * 查询学院专业列表
     */
//    @RequiresPermissions("system:danmoArtMajors:list")
    @PostMapping("/list")
    public Result list(@RequestBody DanmoArtMajors danmoArtMajors)
    {
        List<DanmoArtMajors> list = danmoArtMajorsService.selectDanmoArtMajorsList(danmoArtMajors);
        return Result.success(list);
    }

    /**
     * 导出学院专业列表
     */
//    @RequiresPermissions("system:danmoArtMajors:export")
    @Log(title = "学院专业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtMajors danmoArtMajors)
    {
        List<DanmoArtMajors> list = danmoArtMajorsService.selectDanmoArtMajorsList(danmoArtMajors);
        ExcelUtil<DanmoArtMajors> util = new ExcelUtil<DanmoArtMajors>(DanmoArtMajors.class);
        util.exportExcel(response, list, "学院专业数据");
    }

    /**
     * 获取学院专业详细信息
     */
//    @RequiresPermissions("system:danmoArtMajors:query")
    @GetMapping(value = "/{majorId}")
    public Result getInfo(@PathVariable("majorId") Long majorId)
    {
        return success(danmoArtMajorsService.selectDanmoArtMajorsByMajorId(majorId));
    }

    /**
     * 新增学院专业
     */
//    @RequiresPermissions("system:danmoArtMajors:add")
    @Log(title = "学院专业", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtMajors danmoArtMajors)
    {
        return toAjax(danmoArtMajorsService.insertDanmoArtMajors(danmoArtMajors));
    }

    /**
     * 修改学院专业
     */
//    @RequiresPermissions("system:danmoArtMajors:edit")
    @Log(title = "学院专业", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtMajors danmoArtMajors)
    {
        return toAjax(danmoArtMajorsService.updateDanmoArtMajors(danmoArtMajors));
    }

    /**
     * 删除学院专业
     */
//    @RequiresPermissions("system:danmoArtMajors:remove")
    @Log(title = "学院专业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{majorIds}")
    public Result remove(@PathVariable Long[] majorIds)
    {
        return toAjax(danmoArtMajorsService.deleteDanmoArtMajorsByMajorIds(majorIds));
    }


    /**
     * 查询开设院校
     */
    @GetMapping("/collectionColleges/{name}")
    public Result collectionColleges(@PathVariable String name)
    {
        return danmoArtMajorsService.collectionColleges(name);
    }

    @PostMapping("/listtt")
    public Result listtt(@RequestBody DanmoArtMajors danmoArtMajors)
    {
        List<Map<String, Object>> list = danmoArtMajorsService.selectDanmoArtMajorsListtt(danmoArtMajors);
        return Result.success(list);
    }
}
